<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
 <% include("/WEB-INF/view/console/common/css.html"){}	%>
  <link rel="stylesheet" href="/plugin/bootstrap-table-master/dist/bootstrap-table.css">
 <% include("/WEB-INF/view/console/common/js.html"){} 	%>
  <!--bootstrap table-->
  <script src="${ctxPath}/plugin/bootstrap-table-master/dist/bootstrap-table.js"></script>
  <script src="${ctxPath}/plugin/bootstrap-table-master/dist/locale/bootstrap-table-zh-CN.js"></script>
  <!--delete-->
  <!-- 配置文件 -->
  <script type="text/javascript" src="${ctxPath}/plugin/utf8-jsp/ueditor.config.js"></script>
  <!-- 编辑器源码文件 -->
  <script type="text/javascript" src="${ctxPath}/plugin/utf8-jsp/ueditor.all.js"></script>
  <!-- 实例化编辑器 -->

  <title></title>
 </head>
 <body> <nav class="navbar navbar-default navbar-fixed-top site-navbar" >
  <div class="navbar-header">
 <a class="navbar-brand" href="#">商品信息</a>
 </div>
  </nav>
 <form name="boGoods_form"  id="boGoods_form" class="form-horizontal" style="margin-top: 60px;">
   <div class="form-group" >
 <label class="col-sm-2 control-label">商品名称</label>
 <div class="col-sm-6">
 <input  type="text"  name="goodsTitle" id="goodsTitle" class="form-control" check-type="required" value='${boGoods.goodsTitle!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">商品价格</label>
 <div class="col-sm-6">
 <input  type="text"  name="goodsPrice" id="goodsPrice" class="form-control" check-type="required number" value='${boGoods.goodsPrice!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">商品原价</label>
 <div class="col-sm-6">
 <input  type="text"  name="goodsOriginalPrice" id="goodsOriginalPrice" class="form-control" check-type="required number" value='${boGoods.goodsOriginalPrice!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">商品数量</label>
 <div class="col-sm-6">
 <input  type="text"  name="goodsInventory" id="goodsInventory" class="form-control" check-type="required number" value='${boGoods.goodsInventory!}' >
 </div>
  </div>
 <div class="form-group" >
 <label class="col-sm-2 control-label">商品分类</label>
 <div class="col-sm-6">
 <select   name="goodsTypeId" id="goodsTypeId" class="form-control" check-type="required number"></select>
 </div>
  </div>
  <script>
   $(function($) {
    componentSelectInit(
            {
             ctxPath:'${ctxPath}',
             tableName:"bo_goods_type",
             showValueField:"goods_type_name",
             valueField:"goods_type_id",
             selectId:"goodsTypeId"
            }
            ,function(){
             $("#goodsTypeId").val("${boGoods.goodsTypeId!''}");
            });
   });
  </script>
 <div class="form-group" >
 <label class="col-sm-2 control-label">商品标签</label>
 <div class="col-sm-6">
 <input  type="text"  name="goodsTags" id="goodsTags" class="form-control" check-type="required" value='${boGoods.goodsTags!}' >
 </div>
  </div>
  <div class="form-group" >
   <label class="col-sm-2 control-label">说明</label>
   <div class="col-sm-6">
    <input  type="text"  name="goodsDescription" id="goodsDescription" class="form-control" check-type="required" value='${boGoods.goodsDescription!}' >
   </div>
  </div>
  <div class="form-group" >
   <label class="col-sm-2 control-label">是否推荐</label>
   <div class="col-sm-6">
    <label><input checked='checked' auto_name='boGoods_recommend' type="radio"  name="recommend" value="1"/>是</label>
    <label><input  auto_name='boGoods_recommend' type="radio"  name="recommend" value="2"/>否</label>

   </div>
  </div>
  <script type="text/javascript">
      $(function($){
          $('input[auto_name="boGoods_recommend"]').each(function(){
              if('${boGoods.recommend!}'==this.value){
                  $(this).attr('checked','checked');
              }
          });
      });
  </script>
  <div class="form-group" >
   <label class="col-sm-2 control-label">状态</label>
   <div class="col-sm-6">
    <label><input checked='checked' auto_name='boGoods_state' type="radio"  name="state" value="0"/>不可用</label>
    <label><input  auto_name='boGoods_state' type="radio"  name="state" value="1"/>可用</label>

   </div>
  </div>
  <script type="text/javascript">
      $(function($){
          $('input[auto_name="boGoods_state"]').each(function(){
              if('${boGoods.state!}'==this.value){
                  $(this).attr('checked','checked');
              }
          });
      });
  </script>
  <div class="form-group" >
 <label class="col-sm-2 control-label">商品图片(790*400)</label>
 <div class="col-sm-3">
   <span class="btn btn-success fileinput-button">
        <i class="glyphicon glyphicon-plus"></i>
        <span>添加</span>
  <input type="file" id="goodsImage_file" class="form-control" value='${boGoods.goodsImage!}' >
  <input type="hidden" id="goodsImage"  name="goodsImage"class="form-control" value='${boGoods.goodsImage!}' >
    </span>
  <div id="goodsImage_progress" class="progress">
   <div class="progress-bar progress-bar-success"></div>
  </div>

  </div>
   	<div class="col-sm-4">
   	<img id="goodsImage_file_show" src="${boGoods.goodsImage!}" style="width:100px;" alt="图片" class="img-rounded">
 </div>
 </div>

   <script type="text/javascript"> 
 $(function($){
     consoleUploadAliImg('goodsImage','${ctxPath}');
 });
 </script>

  <div class="form-group" >
   <label class="col-sm-2 control-label">详情</label>
   <div class="col-sm-6">
    <!-- 加载编辑器的容器 -->
    <script id="detail" name="detail" type="text/plain">
         ${detail!}
    </script>
    <script type="text/javascript">
        UE.getEditor('detail');
    </script>
   </div>
  </div>
  <div class="form-group" >
   <label class="col-sm-2 control-label">商品轮播</label>
   <div class="col-sm-8">
    <div id="boGoodsBannerToolbar" class="btn-group">
     <button type="button" class="btn btn-default" onclick="addgb();">
      <i class="glyphicon glyphicon-plus"></i>
     </button>
     <button type="button" class="btn btn-default" onclick='boGoodsBannerConsoleGrid.delete("id","${ctxPath}/console/bo_goods_banner/delete");'>
      <i class="glyphicon glyphicon-trash"></i>
     </button>
    </div>
    <div class='row'>
     <div class='col-md-12'>
      <table id="boGoodsBanner" data-toggle="table"
             data-url="${ctxPath}/console/bo_goods_banner/json"
             data-pagination="true"
             data-query-params="boGoodsBannerLoadParam"
             method="post"
             data-side-pagination="server"
             data-show-refresh="true"
             data-show-toggle="true"
             data-pagination-loop="false"
             data-show-columns="true"
             data-toolbar="#boGoodsBannerToolbar">
       <thead>
       <tr>
        <th data-checkbox="true"></th>
        <th data-field='id' data-visible='false'>ID</th>
        <th data-field='bannerImg' data-sortable='true' data-formatter='boGoodsBannerbanner_imgFormatter'>banner图片</th>
        <th data-sortable='true' data-field='sort'>排序</th>
        <th data-field='status' data-sortable='true' data-formatter='boGoodsBannerstatusFormatter'>状态</th>
        <th data-field='id' data-formatter='boGoodsBannerTableOperate'>操作</th>

       </tr>
       </thead>
      </table>
     </div>
    </div>
   </div>
  </div>
  <div class="form-group" style="margin-bottom: 60px;"></div>

   <input type='hidden' name='goodsId' id='goodsId' value='${boGoods.goodsId!}'><input type='hidden' name='common_token' id='common_token' value='${common_token!}'>

 </form>
 <script type="text/javascript">
 $(function($) {
    /*开启表单验证*/
 	$("#boGoods_form").validation();
 });
 /*保存*/
 function saveZqForm(){
    if ($("#boGoods_form").valid() == false) {
 	    return false;
    }
    var formObject=new Object();
    formObject.goodsTitle=$('#goodsTitle').val()==''?null:$('#goodsTitle').val(); 
 formObject.goodsPrice=$('#goodsPrice').val()==''?null:$('#goodsPrice').val(); 
 formObject.goodsOriginalPrice=$('#goodsOriginalPrice').val()==''?null:$('#goodsOriginalPrice').val(); 
 formObject.goodsInventory=$('#goodsInventory').val()==''?null:$('#goodsInventory').val(); 
 formObject.goodsTypeId=$('#goodsTypeId').val()==''?null:$('#goodsTypeId').val(); 
 formObject.goodsTags=$('#goodsTags').val()==''?null:$('#goodsTags').val(); 
 formObject.goodsImage=$('#goodsImage').val()==''?null:$('#goodsImage').val(); 
 formObject.goodsId=$('#goodsId').val()==''?null:$('#goodsId').val();
     formObject.goodsDescription=$('#goodsDescription').val()==''?null:$('#goodsDescription').val();
     formObject.recommend=($('input[name="recommend"]:checked').val()==''?null:$('input[name="recommend"]:checked').val());
     formObject.state=($('input[name="state"]:checked').val()==''?null:$('input[name="state"]:checked').val());
     var formObjectJson = JSON.stringify(formObject);
    $.post("${ctxPath}/console/bo_goods/save",
     {
           formObjectJson :formObjectJson,
         detail:UE.getEditor('detail').getContent(),
         help:"",
 	   common_token :$("#common_token").val()
     }, function(data) {
        $.confirm({
              title: '提示',
              content: data.message,
              autoClose: 'cancelAction|3000',
              escapeKey: 'cancelAction',
              buttons: {
                  cancelAction: {
                      text: '确定',
                      action: function () {
            parent.$("#boGoods").bootstrapTable("refresh");
          window.location="/console/bo_goods/edit?id="+data.data;
                      }
                  }
              }
 		});
     });
 }
 </script>



 <script type="text/javascript">
  function addgb() {
      var goodsId = "${boGoods.goodsId!}";
      if(goodsId==""){
          $.alert("请先保存商品!");
      }else{
          consoleOpenWindow('boGoodsBanner','${ctxPath}/console/bo_goods_banner/add/'+goodsId,'新增');
      }

  }
     var boGoodsBannerConsoleGrid =new consoleGrid({table_id:"boGoodsBanner"});
     boGoodsBannerConsoleGrid.init();
     function boGoodsBannerTableOperate(value){
         return "<button type='button' class='btn btn-xs btn-default command-edit' onclick='consoleOpenWindow(\"boGoodsBanner\",\"${ctxPath}/console/bo_goods_banner/edit?id="+value+"\",\"编辑\")'><span class='glyphicon glyphicon-pencil'></span></button> ";
     }
     function boGoodsBannerLoadParam(params){
         params.query=boGoodsBannerQueryString();
         return params;
     }
     function boGoodsBannerQueryString() {
         var objQuery = new Object();
         objQuery.goodsId="${boGoods.goodsId!}";
         var queryString = JSON.stringify(objQuery);
         return queryString;
     }

     function boGoodsBannerbanner_imgFormatter(value)
     {
         return '<a href="'+value+'" target="_blank" > <img style="height:50px;" src="'+value+'" alt="缩略图"> </a>';
     }
     function boGoodsBannerstatusFormatter(value)
     {
         var showValue='';
         switch(value+''){
             case '0':
                 showValue = '不可用';
                 break;
             case '1':
                 showValue = '可用';
                 break;
         }
         if(showValue.indexOf('不')!=-1||showValue.indexOf('否')!=-1||showValue.indexOf('禁')!=-1){
             return '<span class="label label-warning">'+showValue+'</span>';
         }else{
             return '<span class="label label-info">'+showValue+'</span>';
         }
     }

 </script>
 <nav class="navbar navbar-default navbar-fixed-bottom site-navbar" >
 <div class="container" style="padding-top:10px;padding-bottom:10px;">
 <div class="nav navbar-nav navbar-right">
 <a href="#" class="btn btn-success"  onclick='saveZqForm()'>保存 </a>
  </div>
  </div>
  </nav>
 </body>
